package main

import (
	"fmt"
	"time"
)

const (
	fmat = "2006-01-02 15:04:05"
)
func main()  {
	ch := make(chan bool)

	go func() {
		defer close(ch)
		time.Sleep(1*time.Second)
		ch<-true
	}()

	for  {
		select {
		case x,ok :=<-ch:
			fmt.Printf("aa%v %v %v\n",time.Now().Format(fmat),x,ok)
			time.Sleep(500*time.Millisecond)
		default:
			fmt.Printf("bb%v",time.Now().Format(fmat))
			time.Sleep(500*time.Millisecond)
		}
	}

}
